/*
 * Copyright 2010 Christoph Widulle (christoph.widulle@googlemail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */



package com.android1.amarena2d.actions.base;

import com.android1.amarena2d.nodes.behavior.ActionTarget;

public class Speed extends Action {

    protected Action other;
    protected float speed;

    public static Speed $(Action other, float speed) {
        return new Speed(other, speed);
    }

    public Speed(Action other, float speed) {
        this.other = other;
        this.speed = speed;
    }

    @Override
    public void tick(float dt) {
        other.tick(dt * speed);
    }

    @Override
    public Speed copy() {
        return Speed.$(other.copy(), speed);
    }

    @Override
    public boolean isDone() {
        return other.isDone();
    }

    @Override
    public void complete(ActionTarget target) {
        other.complete(target);
        super.complete(target);

    }

    @Override
    public Speed reverse() {
        return Speed.$(other.reverse(), speed);
    }
}